package com.hsjk.szwj.module.train.dal.mysql.course;

import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.framework.mybatis.core.mapper.BaseMapperX;
import com.hsjk.szwj.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCourseVideoPageReqVO;
import com.hsjk.szwj.module.train.controller.admin.vo.AdminCourseVideoPageSearchReqVO;
import com.hsjk.szwj.module.train.dal.dataobject.course.CourseVideoDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Arrays;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/08/04 01:30
 **/
@Mapper
public interface ICourseVideoMapper extends BaseMapperX<CourseVideoDO> {
    default PageResult<CourseVideoDO> selectPage(AdminCourseVideoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseVideoDO>()
                .likeIfPresent(CourseVideoDO::getVideoName, reqVO.getVideoName())
                .orderByDesc(Arrays.asList(CourseVideoDO::getCreateTime, CourseVideoDO::getCreateTime)));
    }

    default PageResult<CourseVideoDO> selectPage(AdminCourseVideoPageSearchReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseVideoDO>()
                .eqIfPresent(CourseVideoDO::getVideoName, reqVO.getVideoName())
                .orderByDesc(Arrays.asList(CourseVideoDO::getCreateTime, CourseVideoDO::getCreateTime)));
    }
}
